<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>突出展示</title>
    <style>
        * {
            margin: 0;
            list-style: none;
            padding: 0;
        }
        .img-list {
            width: 300px;
            margin: 20px auto;
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            row-gap: 5px;
            column-gap: 5px;
            padding: 5px;
            background-color: #000;
            border: 1px solid #fff;
        }
        .img-list li {
            font-size: 0px;
        }
        .img-list li img {
            width: 100%;
        }
        .active {
            opacity: 0.5;
        }
    </style>
</head>
<body>
    <ul class="img-list">
        <li><img src="./img/case15/01.webp" alt=""></li>
        <li><img src="./img/case15/02.webp" alt=""></li>
        <li><img src="./img/case15/03.webp" alt=""></li>
        <li><img src="./img/case15/04.webp" alt=""></li>
        <li><img src="./img/case15/05.webp" alt=""></li>
        <li><img src="./img/case15/06.webp" alt=""></li>
    </ul>
    <script>
        const box = document.querySelector(".img-list")
        const allLi = box.querySelectorAll("li")
        allLi.forEach(item=>{
            item.addEventListener("mouseenter",function(){
                allLi.forEach(val=>{
                    val.classList.add("active")
                })
                this.classList.remove("active")
            })
        })
        // 离开大容器的时候 恢复高亮效果
        box.addEventListener("mouseleave",function(){
            allLi.forEach(val=>{
                val.classList.remove("active")
            })
        })

    </script>
</body>
</html>